//
//  BLPhotoView.m
//  新浪微博
//
//  Created by hbl on 16/2/27.
//  Copyright © 2016年 hbl. All rights reserved.
//

#import "BLPhotoView.h"
#import "BLPhoto.h"
#import "UIImageView+WebCache.h"

@interface BLPhotoView()
@property (nonatomic, weak)UIImageView *gitImgView;
@end
@implementation BLPhotoView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        UIImageView *gifImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"timeline_image_gif"]];
        [self addSubview:gifImgView];
        self.gitImgView = gifImgView;
    }
    return self;
}

- (void)setPhoto:(BLPhoto *)photo
{
    _photo = photo;
    self.gitImgView.hidden = ![photo.thumbnail_pic hasSuffix:@"gif"];
    [self sd_setImageWithURL:[NSURL URLWithString:photo.thumbnail_pic] placeholderImage:[UIImage imageNamed:@"timeline_image_placeholder"]];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.gitImgView.layer.anchorPoint = CGPointMake(1, 1);
    self.gitImgView.layer.position = CGPointMake(self.frame.size.width, self.frame.size.height);
}

@end
